package com.doit.day01;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class _02_往mysql中写数据 {
    public static void main(String[] args) throws SQLException {
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "123456");
        PreparedStatement pps = conn.prepareStatement("insert into user_info values(?,?,?,?)");

        //给?赋值
        pps.setInt(1,1);
        pps.setString(2,"zss");
        pps.setInt(3,18);
        pps.setString(4,"male");

        //执行
        pps.execute();
        pps.close();
        conn.close();


    }
}
